<template>
	<view class="page-box">
		<view class="item-box" v-for="(item,index) in listData" :key='index'>
			<view class="top-box">
				<view class="icon-title-box">
					<image class="icon-box" mode="scaleToFill" :src="item.shop.shop_image"></image>
					<view class="title-box">
						{{item.shop.shop_name}}
					</view>
				</view>
				<view :class="item.is_comment == 1 ? 'status-one-box' : 'status-two-box'">
					{{item.is_comment == 1 ? '已评价' : '待评价'}}
				</view>
			</view>
			<view class="line-box">
			</view>
			<view class="price-box">
				<view class="price-item-box">
					消费时间:<text>{{ $u.timeFormat(item.createtime, 'yyyy.mm.dd hh:MM') }}</text>
				</view>
				<view class="price-item-box">
					订单金额:<text>{{item.amount}}</text>
				</view>
				<view class="price-item-box">
					实际支付:<text>{{item.cash_money}}</text>
				</view>
				<view class="price-item-box">
					优惠券抵扣:<text>{{item.hongbao_money}}</text>
				</view>
				<view class="price-item-box">
					代金券抵扣:<text>{{item.daijin_money}}</text>
				</view>
			</view>
			<view class="button-box">
				<view class="btn-one-box" v-if="item.is_comment == 1" @click="checkPingJia(item)">
					查看评价
				</view>
				<view class="btn-two-box" v-else @click="pingJia(item)">
					评价
				</view>
			</view>
		</view>
    <!-- 空置页 -->
    <shopro-empty v-if="isEmpty" marginTop="200rpx" :image="$IMG_URL + '/imgs/empty/no_data.png'" tipText="暂无消费明细">
    </shopro-empty>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				listData: [],
        isEmpty:false,
			}
		},
		onShow() {
			this.getList()
		},
		methods: {
			getList() {
				let params = {
					page: 1,
					limit: 9999,
					token: uni.getStorageSync("token")
				}
				this.$https(
					'mine.orderList', {
						data: params
					},
					'加载中...'
				).then(res => {
					if (res.code === 1) {
						this.listData = res.data.data || []
            this.isEmpty = !this.listData.length;
						console.log(this.listData,'---this.listData')
					} else {
						this.listData = []
						this.$u.toast(res.msg);
					}
				});
			},
			checkPingJia(item){
				uni.navigateTo({
					url: '/pages/index/category/evaluate?isLook=1&orderId='+item.id+"&shop_name="+item.shop.shop_name+"&shop_image="+encodeURIComponent(item.shop.shop_image)
				})
			},
			pingJia(item){
				uni.navigateTo({
					url: '/pages/index/category/evaluate?isLook=0&orderId='+item.id+"&shop_name="+item.shop.shop_name+"&shop_image="+encodeURIComponent(item.shop.shop_image)
				})

			}
		}
	}
</script>

<style scoped lang='scss'>
	.page-box {
		width: 100%;
		height: 100vh;
		padding: 24rpx;
	}

	.item-box {
		margin-bottom: 24rpx;
		width: 100%;
		height: 480rpx;
		background-color: #fff;
	}

	.top-box {
		width: 100%;
		height: 88rpx;
		padding: 0rpx 30rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.icon-title-box {
		display: flex;
		height: 100%;
		align-items: center;

		.icon-box {
			width: 32rpx;
			height: 32rpx;
			border-radius: 32rpx;
		}

		.title-box {
			margin-left: 10rpx;
			font-size: 28rpx;
			font-family: PingFang SC-Bold, PingFang SC;
			font-weight: bold;
			color: #333333;
		}
	}

	.status-one-box {
		font-size: 24rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #999999;
	}

	.status-two-box {
		font-size: 24rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #FE7F1A;
	}

	.line-box {
		margin-left: 30rpx;
		width: calc(100% - 60rpx);
		height: 2rpx;
		background: #F3F3F3;
	}

	.price-box {
		width: 100%;
		height: 272rpx;
		padding: 30rpx 30rpx 0rpx 30rpx;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
	}

	.price-item-box {
		font-size: 28rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: #666666;

		text {
			margin-left: 20rpx;
		}
	}

	.button-box {
		width: 100%;
		height: 118rpx;
		padding-right: 30rpx;
		display: flex;
		justify-content: flex-end;
		align-items: center;
	}

	.btn-one-box {
		width: 162rpx;
		height: 70rpx;
		line-height: 70rpx;
		text-align: center;
		background: #FFFFFF;
		border-radius: 8rpx;
		opacity: 1;
		border: 2rpx solid #F3F3F3;
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #999999;
	}

	.btn-two-box {
		width: 162rpx;
		height: 70rpx;
		line-height: 70rpx;
		text-align: center;
		background: #FC5351;
		border-radius: 8rpx;
		opacity: 1;
		border: 2rpx solid #F3F3F3;
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #fff;
	}
</style>
